package org.jianfa.learn.dubbo.consumer;

import org.apache.dubbo.rpc.RpcContext;
import org.jianfa.learn.dubbo.api.HelloService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.Future;

public class DubboConsumerApplication {

    public static void main(String[] args) throws Exception{
        ClassPathXmlApplicationContext applicationContext  = new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        //applicationContext.start();
        HelloService  helloService  = applicationContext.getBean("helloService", HelloService.class);
        System.in.read();
        System.out.println("Client Request: World");
        String result = helloService.sayHello("World");
        System.out.println("Current Server Response: "+ result);
        // 利用Future 模式来获取
        Future<Object> objectFuture = RpcContext.getContext().getFuture();
        System.out.println("Future Server Response: "+ objectFuture.get());
        System.in.read();
    }
}
